use "${datadir}\HTB_main", replace

*--- Define age groups
egen agecat = cut(age_borrower), ///
	at(18, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 150)

label define agecat 18 "Under 20" ///
                    20 "20-24" ///
					25 "25-29" ///
					30 "30-34" ///
					35 "35-39" ///
					40 "40-44" ///
					45 "45-49" ///
					50 "50-54" ///
					55"55-59" ///
					60 "60-64" ///
					65 "65-69" ///
					70 "70-74" ///
					75 "75 and over"

label value agecat agecat

    
*--- Income stats
gen hh_inc = gross_income * 1000

forvalues i = 0/1 {
	preserve
		keep if htb_dummy == `i'
		collapse (p5) _5th_pct = hh_inc ///
				 (p10) _10th_pct = hh_inc ///
				 (p25) _25th_pct = hh_inc ///
				 (p50) Median = hh_inc ///
				 (p75) _75th_pct = hh_inc ///
				 (p90) _90th_pct = hh_inc ///
				 (p95) _95th_pct = hh_inc ///
				 (count) N = hh_inc, by(agecat)
		export excel using "${tabledir}\pct_age_income_`i'.xlsx", ///
			firstrow(variables) replace
	restore
}
